- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.1k
          Allow events to be created with no prev_events (MSC2716)
          #11243
        
      Conversation
The event still needs to have auth_events defined to be valid. Split out from #11114
prev_eventsprev_events (MSC2716)
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have some tests for this, unless it's expected to be covered by matrix-org/complement#214?
Co-authored-by: Andrew Morgan <[email protected]>
| ), | ||
| AssertionError, | ||
| ) | ||
|  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have some tests for this, unless it's expected to be covered by matrix-org/complement#214?
All of the MSC2716 Complement tests cover this use case since we use it so much there. I've just added some integration tests for this.
I didn't add tests for every case to be completely exhaustive but did make sure this extra functionality works and that we don't allow events with empty auth_events
- Creating a m.room.createevent- ❌ In MSC2716 room version
- ❌ In existing stable room version
 
- Creating event with empty prev_event- ✅ In MSC2716 room version
- ❌ In existing stable room version
 
- Creating event with empty prev_eventand emptyauth_event(make sure rejected)- ✅ In MSC2716 room version
- ❌ In existing stable room version
 
- Creating event with prev_events- ❌ In MSC2716 room version
- ❌ In existing stable room version
 
- Creating event with prev_eventsbut emptyauth_event(make sure rejected)- ❌ In MSC2716 room version
- ❌ In existing stable room version
 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tests! This lgtm, I'd like to just ask another member of the team to double-check the changes make sense (and don't have any security implications).
Previously just a copy paste Co-authored-by: Andrew Morgan <[email protected]>
| msc2403_knocking = attr.ib(type=bool) | ||
| # MSC2716: Adds m.room.power_levels -> content.historical field to control | ||
| # whether "insertion", "chunk", "marker" events can be sent | ||
| msc2716_historical = attr.ib(type=bool) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tests! This lgtm, I'd like to just ask another member of the team to double-check the changes make sense (and don't have any security implications).
Thanks for the review @anoadragon453 🦈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise lgtm
| I've noticed that interestingly, we seem to have attempts to create events without  | 
| see #8094 for some background on that assertion. I'm not enthusiastic about any change which makes it more likely for us to start accidentally creating regular events without  | 
> if `len(auth_event_ids) == 0` then `auth_event_ids` will be falsey, so the extra check is redundant. > > -- #11243 (comment)
        
          
                synapse/handlers/message.py
              
                Outdated
          
        
      | builder.type == EventTypes.Create or len(prev_event_ids) > 0 | ||
| ), "Attempting to create an event with no prev_events" | ||
| room_version_obj = await self.store.get_room_version(builder.room_id) | ||
| if room_version_obj.msc2716_empty_prev_events: | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be good, but will obviously not be backwards compatible. We probably want to add this to a new room version?
Does this actually require a new room version? (discussed at #11114 (comment))
My thinking is that this code is only for creating events, not accepting events. So technically any other homeserver nowadays can create events with no prev_events now and it would work in existing room versions.
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not that surprised that we accept outliers with empty prev-events, but we'll need special handling for the insertion event to be accepted, i.e. we'll need some sort of check like "this is an insertion event so we need to go and fetch the state rather than trying to calculate it". Though that can be part of the history import MSC I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll need special handling for the insertion event to be accepted, i.e. we'll need some sort of check like "this is an insertion event so we need to go and fetch the state rather than trying to calculate it"
Why is this the case? It seems to work in my Complement tests without any of this 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spooky! 👻  Is it doing something silly like dropping the event with no extremities and then doing a /state on the event that references it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure yet. If you really want me to dive into it, I can ⛳
| # prev_event_ids could be an empty array though. | ||
| assert prev_event_ids is not None | ||
|  | ||
| # Copy the full auth state before it stripped down | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separately: I'm not sure its correct that the insertion event points to anything else, as we need want federation to ask for the state at the insertion event, rather than any of the state events that it references?
The insertion event is connected to the state chain so the whole historical batch can share the same state_group, see #10975. It also looks nice in the DAG semantically to be able to see the state that authed the batch.
For the federation cases, it seems to work 🤔🤷. auth_event_ids probably
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that surprises me a bit. I was very much imagining that the federation code would ask for the state at the insertion event. I guess it probably works because we fetch the state at the start of the chain of state events? And we return the full state, so we then can accept all the state events we add? I don't think that is necessary to make the whole batch have the same state group.
Also, I wonder if that'll make the client UI show the state events when backpaginating, making it look like the state was changed at those points, when actually they were changed much further back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that is necessary to make the whole batch have the same state group.
I can play around with it but that seems like something for another PR. It's pretty finicky to get right.
Also, I wonder if that'll make the client UI show the state events when backpaginating, making it look like the state was changed at those points, when actually they were changed much further back?
Doesn't seem to be a problem for the local origin homeserver with Element probably because they are marked as outliers 🤔
I want to test this on a federated homeserver though.
I'm trying to setup a federated homeserver locally to see if it's a problem for remote federated servers. Currently working out the hostname/server_name problem mapping to a port on localhost (tips welcome) and basing the config off of the demo script. I'm attempting to use /etc/hosts and a nginx reverse proxy to 127.0.0.1:8448 (non-tls) . Synapse is configured to be tls: false on 8008 and 8448. This appears to work to get my.matrix.host and other.matrix.host resolving but doesn't make Synapse happy enough to be able to successfully fetch the room list between each other.
Might just end up creating a Complement test around making sure the state isn't visible between batches ⏩ but would be nice to double-check with real Element about how it looks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to setup a federated homeserver locally to see if it's a problem for remote federated servers.
FYI you can start some preconfigured HSes that federate with each other by running ./demo/start.sh (and ./demo/stop.sh)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I wonder if that'll make the client UI show the state events when backpaginating, making it look like the state was changed at those points, when actually they were changed much further back?
Might just end up creating a Complement test around making sure the state isn't visible between batches ⏩ but would be nice to double-check with real Element about how it looks.
I updated the Complement test which tests multiple batches over federation to check for historical state and didn't see any problems between batches. But when the historical state chain is connected to the insertion event, it does show up before the creation event. Not sure how Element handles events before the creation event 🤷♀️
(image is in scrollback order, oldest messages at the top)

/messages response
{"chunk":[{"content":{"org.matrix.msc2716.marker.insertion":"$WaBcgnXayK2kF09ZpmfCftYGIxrtVkFoNvHh6aeU424"},"origin_server_ts":1638421073731,"room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","type":"org.matrix.msc2716.marker","unsigned":{"age":7480},"event_id":"$lS2ED7HslhXZkRx8VL1TXKDY3f_BKwFHUiQWs00dYa0","user_id":"@the-bridge-user:hs1","age":7480},{"type":"m.room.member","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@charlie:hs2","content":{"membership":"join","displayname":"charlie","avatar_url":null},"state_key":"@charlie:hs2","origin_server_ts":1638421073600,"unsigned":{"age":7604},"event_id":"$O-pdVPKIVSMkeM3HYVrZlGOOlT_vOB-a89neIAtc6xM","user_id":"@charlie:hs2","age":7604},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@alice:hs1","content":{"body":"Message 1 (eventIDsAfter)","msgtype":"m.text"},"origin_server_ts":1638421072318,"unsigned":{"age":1578},"event_id":"$g1ARnN19QFCcjwn1uhB_i8QOyWI-DO0re-UkcD-vx-w","user_id":"@alice:hs1","age":1578},{"type":"org.matrix.msc2716.insertion","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"org.matrix.msc2716.next_batch_id":"bWoojCNr","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072237,"unsigned":{"age":1464},"event_id":"$WaBcgnXayK2kF09ZpmfCftYGIxrtVkFoNvHh6aeU424","user_id":"@the-bridge-user:hs1","age":1464},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@alice:hs1","content":{"body":"Message 0 (eventIDsAfter)","msgtype":"m.text"},"origin_server_ts":1638421072266,"unsigned":{"age":1630},"event_id":"$FIvwe-eNldbj7tBHuF2T7WDxQm9V359KWOf-cRtKWSo","user_id":"@alice:hs1","age":1630},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 9 (batch=0)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072237,"unsigned":{"age":1612},"event_id":"$umIFPlRr2XmB3fick6hV7Y3QhkpxcYjnjukqmSLE5aQ","user_id":"@maria:hs1","age":1612},{"type":"org.matrix.msc2716.batch","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"org.matrix.msc2716.batch_id":"bWoojCNr","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072237,"unsigned":{"age":1433},"event_id":"$0bFJFfzv7E6COheiVMKxA1YfzX3ashIRPZXSZHROj7w","user_id":"@the-bridge-user:hs1","age":1433},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 8 (batch=0)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072236,"unsigned":{"age":1640},"event_id":"$z3OxR4a5TDfrSKEOie2NNaXmKmf6JPNsDPrPeT7_wYQ","user_id":"@maria:hs1","age":1640},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 7 (batch=0)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072235,"unsigned":{"age":1670},"event_id":"$vTZCRWjTrhK4patXggIjatGjSPZCFwOaYdSprU0q6wM","user_id":"@maria:hs1","age":1670},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 6 (batch=0)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072234,"unsigned":{"age":2205},"event_id":"$leVj2y-j_050_u6JADUiLwpEUdgnU5KUNDwxgcqb8L4","user_id":"@maria:hs1","age":2205},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 5 (batch=0)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072233,"unsigned":{"age":2745},"event_id":"$rQCHqPz54-EzCBPjM8euve-9bx3UOnYQvzctG1FrCe8","user_id":"@maria:hs1","age":2745},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 4 (batch=0)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072232,"unsigned":{"age":2780},"event_id":"$zmvZmUOtdMf32G4zW-VkfRCeN7y7vQY0jKcAmK3Dpeo","user_id":"@maria:hs1","age":2780},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 3 (batch=0)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072231,"unsigned":{"age":2813},"event_id":"$bZje4pt6EBeUQWO7itQsvjLpS-BzqXyaemqlUvxejW8","user_id":"@maria:hs1","age":2813},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 2 (batch=0)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072230,"unsigned":{"age":2846},"event_id":"$870hp6qsrfMrouJtEfpUAQwmRJCqaVbz4-P0OFeCMgo","user_id":"@maria:hs1","age":2846},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 1 (batch=0)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072229,"unsigned":{"age":3378},"event_id":"$Hj66b_hjH4day9qZX9RB3QNV9sTEg-0r2u4jhQECFQM","user_id":"@maria:hs1","age":3378},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 0 (batch=0)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072228,"unsigned":{"age":3921},"event_id":"$YMU4z7whUw8clargTpTYJ_rE8TbdIsGZpSyReHKrhm8","user_id":"@maria:hs1","age":3921},{"type":"org.matrix.msc2716.insertion","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"org.matrix.msc2716.next_batch_id":"DLkCgJwG","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072228,"unsigned":{"age":3965},"event_id":"$waIk9kxoQ6m8BQOrBAt0XMfmmVfD4WDXe5A4NJnPAM0","user_id":"@the-bridge-user:hs1","age":3965},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 9 (batch=1)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072227,"unsigned":{"age":3767},"event_id":"$wHINyaKdsd5xjxqO-BMDThuEBk2aOt2sJZGZzhwipCs","user_id":"@maria:hs1","age":3767},{"type":"org.matrix.msc2716.batch","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"org.matrix.msc2716.batch_id":"DLkCgJwG","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072227,"unsigned":{"age":1253},"event_id":"$sztVY6kBjSev1X3Hm6BViRNYyc1cQS5Vhjyt9lAMyMU","user_id":"@the-bridge-user:hs1","age":1253},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 8 (batch=1)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072226,"unsigned":{"age":3803},"event_id":"$GqXxKglEtttl-iIcpjDqShn5OTkW07SipgCzCq2iAjY","user_id":"@maria:hs1","age":3803},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 7 (batch=1)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072225,"unsigned":{"age":3838},"event_id":"$ZFDgIDCUMfs-qHDlSQW8F-LWiKIFRiHgTCqaXlPLe4k","user_id":"@maria:hs1","age":3838},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 6 (batch=1)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072224,"unsigned":{"age":4376},"event_id":"$oEVuLh6ZcbQGD3aeFkr2tYUwtCCkyO5qGAFGz2fLTnw","user_id":"@maria:hs1","age":4376},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 5 (batch=1)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072223,"unsigned":{"age":4917},"event_id":"$5x2BQurlJ3T4GcspRlF8fOW9CrwKwkauAgkgBXOjVSc","user_id":"@maria:hs1","age":4917},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 4 (batch=1)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072222,"unsigned":{"age":4956},"event_id":"$r4e4rp9HuJ2gW_-1U4favhRTiqIsYeQXlG4L9b8RvEA","user_id":"@maria:hs1","age":4956},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 3 (batch=1)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072221,"unsigned":{"age":4990},"event_id":"$I-Vc7nCmA2UI9zCW0jsjA9QU-xo8XrRa9crUCikQ484","user_id":"@maria:hs1","age":4990},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 2 (batch=1)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072220,"unsigned":{"age":5023},"event_id":"$kew5mWiogSEWq5WJiIwqoylrmC4Mbi63EXT63H-lmIY","user_id":"@maria:hs1","age":5023},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 1 (batch=1)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072219,"unsigned":{"age":5554},"event_id":"$SKCLLf0Aok4urhbf-0wY_r_ACEAjaPi9pjec62fYpVE","user_id":"@maria:hs1","age":5554},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 0 (batch=1)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072218,"unsigned":{"age":6099},"event_id":"$14kxr9vQItjx2JawLphSmrj1Jwr8kfc_EOx-gT-iong","user_id":"@maria:hs1","age":6099},{"type":"org.matrix.msc2716.insertion","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"org.matrix.msc2716.next_batch_id":"CoyLEmTJ","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072218,"unsigned":{"age":6140},"event_id":"$gZx6dAB98BmyjAdCVZKgayF_c4L_gz1cy45i-8N4fSI","user_id":"@the-bridge-user:hs1","age":6140},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 9 (batch=2)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072217,"unsigned":{"age":5947},"event_id":"$pFssNAX_rVeY_PhxSSMquxHLZXr5oN05Fiv_QfPCvkE","user_id":"@maria:hs1","age":5947},{"type":"org.matrix.msc2716.batch","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"org.matrix.msc2716.batch_id":"CoyLEmTJ","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072217,"unsigned":{"age":1069},"event_id":"$JVTwaVHhgnW8cfjVqW-pS_5mhODVJZa4PVHxdG1Efzc","user_id":"@the-bridge-user:hs1","age":1069},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 8 (batch=2)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072216,"unsigned":{"age":5980},"event_id":"$qCMOwxe1GrVNzyWKN3zaQ-lg3lW1DUNrpfoRnebWFm4","user_id":"@maria:hs1","age":5980},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 7 (batch=2)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072215,"unsigned":{"age":6012},"event_id":"$UfDaJL_LPXVwXKKQs73XzYmI-Uir4jN7W6IziZ2SCYI","user_id":"@maria:hs1","age":6012},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 6 (batch=2)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072214,"unsigned":{"age":6552},"event_id":"$TeMnyuzXPRShgq3Fh1pQN96cssNHqtH4iGTvK8ZHAMw","user_id":"@maria:hs1","age":6552},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 5 (batch=2)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072213,"unsigned":{"age":7089},"event_id":"$Cn4JfL0SeaTBiRd_LNqZAVuvMmR8AvGUKYCOjg5uTt0","user_id":"@maria:hs1","age":7089},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 4 (batch=2)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072212,"unsigned":{"age":7126},"event_id":"$V9_aO69DgrYi2WMiPmgPcUuvD05dyncCldrKtUfzZSA","user_id":"@maria:hs1","age":7126},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 3 (batch=2)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072211,"unsigned":{"age":7164},"event_id":"$tJvxEsxTR9HJliBPcNSvJFmOY94ciipYTAXUov_K_Yo","user_id":"@maria:hs1","age":7164},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 2 (batch=2)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072210,"unsigned":{"age":7200},"event_id":"$Rdp3bV85LI-s3PvGmUOruK2TltWpULtpYcJ5WKQg6m8","user_id":"@maria:hs1","age":7200},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 1 (batch=2)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072209,"unsigned":{"age":7741},"event_id":"$gs5cV3RM2-TuKjGz0BGPsxlrMdUNVD0cjgdx1H7hQdE","user_id":"@maria:hs1","age":7741},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"body":"Historical 0 (batch=2)","msgtype":"m.text","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072208,"unsigned":{"age":8286},"event_id":"$kqSb-7ejvJqCbMw0n3HoNtlX1xLV_vqoj0p5pmyp6Os","user_id":"@maria:hs1","age":8286},{"type":"org.matrix.msc2716.insertion","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"org.matrix.msc2716.next_batch_id":"nhKNQtdq","org.matrix.msc2716.historical":true},"origin_server_ts":1638421072208,"unsigned":{"age":8335},"event_id":"$QWeEjdorD08UUrOSv4V51uruiFwN9AW2pyhMtjTKdWc","user_id":"@the-bridge-user:hs1","age":8335},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@alice:hs1","content":{"body":"Message 1 (eventIDsBefore)","msgtype":"m.text"},"origin_server_ts":1638421072192,"unsigned":{"age":1704},"event_id":"$o9SYeHYTCBmh7I8oQUuYrYiunNnRh6hm-hajCz_uVn8","user_id":"@alice:hs1","age":1704},{"type":"m.room.message","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@alice:hs1","content":{"body":"Message 0 (eventIDsBefore)","msgtype":"m.text"},"origin_server_ts":1638421072119,"unsigned":{"age":1777},"event_id":"$tvHWwYy5am7_ivgPNMRMevMdbEnYldR0cOJzV4IK9D0","user_id":"@alice:hs1","age":1777},{"type":"m.room.member","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@alice:hs1","content":{"membership":"join","displayname":"alice"},"state_key":"@alice:hs1","origin_server_ts":1638421072077,"unsigned":{"age":1565},"event_id":"$ejmNHLgOrZ_dDN0CsooWespSg0vZ8zVTl77M12ke_PY","user_id":"@alice:hs1","age":1565},{"type":"m.room.name","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"name":"the hangout spot"},"state_key":"","origin_server_ts":1638421072038,"unsigned":{"age":1604},"event_id":"$MM3mC6Ig2bVODUcI1EEphKLBO_q2t0jXCErMxpdFgaM","user_id":"@the-bridge-user:hs1","age":1604},{"type":"m.room.history_visibility","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"history_visibility":"shared"},"state_key":"","origin_server_ts":1638421072010,"unsigned":{"age":1632},"event_id":"$M6OepRC0jQYBjmv7sQNup4MiJIdMG8TbdDBO0cMkVZ8","user_id":"@the-bridge-user:hs1","age":1632},{"type":"m.room.join_rules","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"join_rule":"public"},"state_key":"","origin_server_ts":1638421071982,"unsigned":{"age":1660},"event_id":"$H0JEhKMu0cbWH6lnIu_UpKWWh9ooVq3Wu3Dgj9SPUF0","user_id":"@the-bridge-user:hs1","age":1660},{"type":"m.room.power_levels","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"users":{"@the-bridge-user:hs1":100},"users_default":0,"events":{"m.room.name":50,"m.room.power_levels":100,"m.room.history_visibility":100,"m.room.canonical_alias":50,"m.room.avatar":50,"m.room.tombstone":100,"m.room.server_acl":100,"m.room.encryption":100},"events_default":0,"state_default":50,"ban":50,"kick":50,"redact":50,"invite":50,"historical":100},"state_key":"","origin_server_ts":1638421071938,"unsigned":{"age":1704},"event_id":"$5vDhHe7-M7M_hET9i2-MhLESIDILl9r9HadKksWbtos","user_id":"@the-bridge-user:hs1","age":1704},{"type":"m.room.member","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"membership":"join"},"state_key":"@the-bridge-user:hs1","origin_server_ts":1638421071897,"unsigned":{"age":1745},"event_id":"$7IaD95Sp4SRExyY971nzbcXgI9S67pQ9FnfdMIEjheI","user_id":"@the-bridge-user:hs1","age":1745},{"type":"m.room.create","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@the-bridge-user:hs1","content":{"room_version":"org.matrix.msc2716v4","creator":"@the-bridge-user:hs1"},"state_key":"","origin_server_ts":1638421071834,"unsigned":{"age":1808},"event_id":"$yigMLKdi72kpZFdwTpJL-s71lV_vLqJAKgVeboqXA-g","user_id":"@the-bridge-user:hs1","age":1808},{"type":"m.room.member","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"displayname":"some-display-name-for-@maria:hs1","membership":"join","org.matrix.msc2716.historical":true},"state_key":"@maria:hs1","origin_server_ts":1638421072739,"unsigned":{"age":1158},"event_id":"$Ean2gLNBtIH6CHaSQ5XicbIZ1pYk-N7PFIO9RTytSM0","user_id":"@maria:hs1","age":1158},{"type":"m.room.member","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"displayname":"some-display-name-for-@maria:hs1","membership":"join","org.matrix.msc2716.historical":true},"state_key":"@maria:hs1","origin_server_ts":1638421072570,"unsigned":{"age":1327},"event_id":"$LJUfF9Eo58Nbq7cNYoN-oGowd_OwfzgUkux4O3Ksikk","user_id":"@maria:hs1","age":1327},{"type":"m.room.member","room_id":"!FRNexMHUjKhRxPvPzq:hs1","sender":"@maria:hs1","content":{"displayname":"some-display-name-for-@maria:hs1","membership":"join","org.matrix.msc2716.historical":true},"state_key":"@maria:hs1","origin_server_ts":1638421072370,"unsigned":{"age":1527},"event_id":"$OIbefO5BM9jGxwk7_lF3Wdy9gO-PG1ZuGq2rQscznOg","user_id":"@maria:hs1","age":1527}],"start":"s3_0_0_0_0_0_0_0_0","end":"t1--13_0_0_0_0_0_0_0_0"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that is necessary to make the whole batch have the same state group.
I created #11487 to add a test to ensure the state_groups are shared.
Things seem to work just fine if I disconnect the floating state chain from the insertion event so we can move forward with that in #11114 (comment) after this merges.
Both the state chain and the insertion event chain can float with no prev_events. No issues with shared state_groups, accepting over federation, and the historical state does not show up at all in /messages
> if `len(auth_event_ids) == 0` then `auth_event_ids` will be falsey, so the extra check is redundant. > > https://github.com/matrix-org/synapse/pull/11243/files#discussion_r745985469
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me, sorry for long RTT ❤️
| Thanks for the review @erikjohnston @anoadragon453 @richvdh 🦎 Happy to see this one get across the line! 🥌 | 
Allow events to be created with no
prev_events. The event still needs to haveauth_eventsdefined to be valid.Split out from #11114
Dev notes
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.Pull request includes a sign off(run the linters)